//
//  NationalBondsExchangeJa.m
//  MarketDataColloctor
//
//  Created by jiro on 10/03/27.
//  Copyright 2010 jiro music. All rights reserved.
//

#import "NationalBondsExchangeJa.h"
//#import "../DbConstants.h"
#import "../../DbTypes.h"

@implementation NationalBondsExchangeJa

@synthesize interestRate;

+ (NationalBondsExchangeJa*) nationalBondsExchangeJaWithValues: (NSArray*) values
{
	NationalBondsExchangeJa* value = [ [ NationalBondsExchangeJa alloc ] init ];
	value.code = [ values objectAtIndex: 0 ];
	value.exchangeDate = [ NSDate dateWithString: 
		[ DbUtility convertIsoStdDateStringToCocoaDateString: [ values objectAtIndex: 1 ] ] ];
	value.interestRate = [ [ values objectAtIndex: 2 ] floatValue ];
	return value;
}

+ (NSString*) tableName
{
	return kText_JaNationalBondsExchange;
}

+ (NSString*) queryCreateTable
{
	return [ NSString stringWithFormat:
		@"create table %@ ( %@ %@, %@ %@, %@ %@, %@( %@, %@ ) );",
		[ NationalBondsExchangeJa tableName ], 
		kText_Code,			kText_Text,
		kText_ExchangeDate,	kText_TimestampWithTimeZone,
		kText_InterestRate,	kText_Real,
		kText_PrimaryKey,	kText_Code, kText_ExchangeDate 
	];
}

- (NSString*) tableName
{
	return [ NationalBondsExchangeJa tableName ];
}

- (NSString*) sqlInsertStatement
{
	return [ NSString stringWithFormat:
		@"insert into %@ values %@;",
		[ NationalBondsExchangeJa tableName ], [ self queryInsertValue ]
	];
}

+ (NSString*) querySelectAll
{
	NSString* s = [ NSString stringWithFormat: @"select * from %@;", [ NationalBondsExchangeJa tableName ] ];
	return s;
}

- (NSString*) queryInsert
{
	NSString* s = [ NSString stringWithFormat: @"insert into * values %@;", 
		[ NationalBondsExchangeJa tableName ], [ self queryInsertValue ] ];
	return s;
}

- (NSString*) queryInsertValue
{
	return [ NSString stringWithFormat:
		@"( '%@', '%@', %f )",
		code, exchangeDate, interestRate
	];
}

@end
